<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <!-- ul>li{$}*10     -->
    <h3>事件委托优点</h3>
    <p>
      1.
      内存占用减少，只需要为一个父元素绑定事件处理程序，而不必为每个后代添加事件处理程序
    </p>
    <p>2. 增加或删除元素无需解绑或者重新绑定事件</p>
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>6</li>
      <li>7</li>
      <li>8</li>
      <li>9</li>
      <li>10</li>
    </ul>
  </body>
  <script>
    const ul = document.querySelector('ul')
    ul.addEventListener('click', e => {
      const html = e.target.innerHTML
      alert(html)
    })
  </script>
</html>
